﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace com.ebc.framework {
    
    public abstract class EventBasedComponentBase<TIn, TOut> {
        
        public InPin<TIn> In_Signal;
        public event OutPin<TOut> Out_Signal;
        public event OutExceptionPin Out_Exception;

        protected EventBasedComponentBase() {
            this.In_Signal.WireTo<TIn>(this.RecieveInSignal);
        }

        protected abstract void RecieveInSignal(TIn signal);

        protected virtual void OnOutSgnal(TOut outSignal) {
            if (this.Out_Signal != null) {
                this.Out_Signal(outSignal);
            }
        }

        protected virtual void OnExceptionTrows(Exception exeption) {
            if (this.Out_Exception != null) {
                this.Out_Exception(exeption);
            }
        }
    }
}
